package ifi.p17.thai_cisse;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 */
public class utils {


    public static String getFilename(String filePath) {
        String fileName = "";
        try {
            String[] strArray = filePath.split("/");
            fileName = strArray[strArray.length - 1];
        } catch (NullPointerException ne) {
        }
        return fileName;
    }

    public static boolean isPhoneNumberValid(String phoneNumber) {
        boolean isValid = false;
        String expression = "^\\(?(\\d{3})\\)?[- ]?(\\d{3})[- ]?(\\d{4})$";
        CharSequence inputStr = phoneNumber;
        Pattern pattern = Pattern.compile(expression);
        Matcher matcher = pattern.matcher(inputStr);
        if (matcher.matches()) {
            isValid = true;
        }
        return isValid;
    }
}
